package com.sunlands.deskmate.message.handler.storager.interceptor;

import com.sunlands.deskmate.message.entity.Messages;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 消息前置处理器
 */
@Component
public class MessagePreInterceptorChain {

    private volatile List<Interceptor> beforeChain;

    public MessagePreInterceptorChain(List<Interceptor> beforeChain) {
        this.beforeChain = beforeChain;
    }

    //消息处理前置拦截器执行
    public boolean interceptor(Messages msgEntity) {
        for (Interceptor interceptor : beforeChain) {
            if (!interceptor.interceptor(msgEntity)) {
                return false;
            }
        }
        return true;
    }

}
